package com.guchenbo.example.httpclient;

import org.apache.http.auth.AuthScope;
import org.apache.http.auth.Credentials;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;

public class CustomCredentialProvider implements CredentialsProvider {

    private String userName;
    private String password;

    public CustomCredentialProvider(String userName, String password) {
        this.userName = userName;
        this.password = password;
    }

    @Override
    public void setCredentials(AuthScope authscope, Credentials credentials) {

    }

    @Override
    public Credentials getCredentials(AuthScope authscope) {
        return new UsernamePasswordCredentials(userName.trim(), password.trim());
    }

    @Override
    public void clear() {

    }
}
